package com.shenzhenai.module_design_partterns.class2;

import com.shenzhenai.module_design_partterns.class1.CashNormal;
import com.shenzhenai.module_design_partterns.class1.CashRebate;
import com.shenzhenai.module_design_partterns.class1.CashReturn;
import com.shenzhenai.module_design_partterns.class1.CashSuper;

/**
 * @author huangzehui
 * @date 2025/8/8 13:40 周五
 * @description
 */
public class CashContext {
    private CashSuper cs;

    public CashContext(String type) {
        this.cs = switch (type) {
            case "正常消费" -> new CashNormal();
            case "满300返100" -> new CashReturn(300, 200);
            case "打8折" -> new CashRebate(0.80);
            default -> throw new IllegalArgumentException("Unexpected value: " + type);
        };;
    }

    public double getResult(double money){
        return cs.acceptCash(money);
    }
}
